<?php
$NAME="海涛网上平价超市";
$TITLE="水/饮料/乳制品 价格详情 -零食 吃货 海涛零食 海涛超市 化妆品 便宜，方便，放心的网上平价超市";

$category=-1;
if(isset($_GET['c'])){
	$category=$_GET['c'];
}

require_once('func.php');

$result=$db->get_all('select name,pic_link,prime_price,price from product where category=0');

$father=$db->get_all("select * from category where id=$category");
if(count($father)!=0 && $father[0]['father']!=0) {
	$current_id=$father[0]['father'];
}
else
	$current_id=$category;
$current='';
$other=array();
$one_level=$db->get_all("select * from category where father=0");
foreach($one_level as $value){
	if ($value['id']==$current_id){
		$value['child']=$db->get_all("select * from category where father=${value['id']}");
		$current=$value;
		continue;
	}
	$value['child']=$db->get_all("select * from category where father=${value['id']}");
	array_push($other, $value);
}
?>
<!DOCTYPE html>  
<html>  
<head>
  <Meta http-equiv="Content-Type" Content="text/html; Charset=UTF-8">
  <Meta http-equiv="Content-Language" Content="zh-CN">

  <META NAME="Title" CONTENT="零食 吃货 海涛零食 海涛超市 化妆品 便宜，方便，放心的网上平价超市">
  <META NAME="Author" CONTENT="www.haitaocs.com">
  <META NAME="Subject" CONTENT="海涛零食 海涛超市 零食 化妆品 便宜，方便，放心的网上平价超市">
  <META NAME="Description" CONTENT="提供各种时尚，可口的美味零食，以及流行美丽的化妆护理用品">
  <META NAME="Keywords" CONTENT="零食;吃货;海涛零食;海涛超市;时尚美食;美味零食;">
  <META NAME="Generator" CONTENT="零食;吃货;海涛零食;海涛超市;时尚美食;美味零食;">
  <META NAME="Language" CONTENT="zh-CN">
  <META NAME="Abstract" CONTENT="本店提供各种零食，小吃，特产以及化妆护理用品">
  <META NAME="Copyright" CONTENT="www.haitaocs.com">
  <META NAME="Designer" CONTENT="www.haitaocs.com">
  <META NAME="Publisher" CONTENT="www.haitaocs.com">
  <META NAME="Robots" CONTENT="All">  
  <title><?php echo $TITLE; ?></title> 

  <!-- mobile viewport optimisation -->
  <meta name="viewport" content="width=device-width, initial-scale=1.0">

  <!-- stylesheets -->
  <link rel="stylesheet" href="css/styles.css" type="text/css"/>
  <link rel = "Shortcut Icon" href="favicon.ico" >  
 

  <!--[if lte IE 7]>
  <link rel="stylesheet" href="yaml/core/iehacks.min.css" type="text/css"/>
  <![endif]-->

</head>  
<body>
  <header>
    <div class="ym-wrapper">
      <div class="head-wbox">
        <div id="head" >
            <a href="http://haitaochaoshi.taobao.com/"><img src="img/logo.png" /></a>
			<div id="head_right">
				<form id="search" onsubmit="return false;" >
					<span>我要买:</span><input type="text" id="keyword" name="keyword" value="输入商品关键字" onkeydown="keycheck();" /> <input type="button" value="搜索商品" onclick="do_search();" />
				</form>
				<div id="link" ></div>
			</div>
        </div>
      </div>
    </div>
  </header>
  <div id="nav">
      <div class="nav-wbox">
			<ul id="sddm">
				<li <?php if($category==0){echo "class=\"active\"";} ?> ><a href="index.php?c=0" >首页</a></li>
				<?php
					if($category>0){
						$id=$current['id'];
						echo "<li class=\"active\" ><a href=\"index.php?c=$id\" onmouseover=\"mopen('m$id')\" onmouseout=\"mclosetime()\">${current['desc']}</a>
							 <div id=\"m$id\" onmouseover=\"mcancelclosetime()\" onmouseout=\"mclosetime()\">";
					    foreach($current['child'] as $child){
							echo "<a href=\"index.php?c=${child['id']}\"> ${child['desc']} </a>";
						}		
						echo"</div></li>";
					}
					foreach($other as $value){
						$id=$value['id'];
						echo "<li><a href=\"index.php?c=$id\" onmouseover=\"mopen('m$id')\" onmouseout=\"mclosetime()\">${value['desc']}</a>
                             <div id=\"m$id\" onmouseover=\"mcancelclosetime()\" onmouseout=\"mclosetime()\">";
						foreach($value['child'] as $child) {
							echo "<a href=\"index.php?c=${child['id']} \"> ${child['desc']} </a>";
						}
						echo"</div></li>";
					} 
				?>
			</ul>
			<div style="clear:both"></div>
      </div>
  </div>
  <div id="main">
    <div class="ym-wrapper">
      <div class="ym-wbox">
			<div id="title">水/饮料/乳制品 价格详情:</div>
		<?php
			foreach($result as $item){
			echo "
			<div class=\"box_w\">
                <div class=\"img_w\" ><img src=\"${item['pic_link']}\"></div>
                <div class='name'>${item['name']}</div>
                <div class='p1'>原价:${item['prime_price']}</div>
                <div class='p2'>现价:${item['price']}</div>
			</div>
			";
		} 
		?>		
      </div>
    </div>
  </div>
 
  <footer>
    <div class="ym-wrapper">
      <div class="ym-wbox">
        hello
      </div>
    </div>

	<style type="text/css">
		#title{margin:10px; font:bold 2em "宋体",Arial,Times;}
		.img_w img{height:100px;width:100px;}
		.img_w {height:100px;width:100px;position:absolute;top:0px;left:0px;padding:10px;}
		.name {height:20px;width:480px;position:absolute;top:10px;left:130px;}
		.p1 {height:20px;width:480px;position:absolute;top:50px;left:130px;}
		.p2 {height:20px;width:480px;position:absolute;top:90px;left:130px;}
		.box_w {border:1px solid red;height:120px;width:600px; position:relative;margin:10px;}
	</style>

	<script type="text/javascript">
		/*
		导航栏js代码开始
		*/
		var timeout         = 200;
		var closetimer          = 0;
		var ddmenuitem      = 0;
		// open hidden layer
		function mopen(id)
		{
		        // cancel close timer
		        mcancelclosetime();
		
		        // close old layer
		        if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
		
		        // get new layer and show it
		        ddmenuitem = document.getElementById(id);
		        ddmenuitem.style.visibility = 'visible';
		
		}
		// close showed layer
		function mclose()
		{
		        if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
		}
		// go close timer
		function mclosetime()
		{
		        closetimer = window.setTimeout(mclose, timeout);
		}
		// cancel close timer
		function mcancelclosetime()
		{
		        if(closetimer)
		        {
		                window.clearTimeout(closetimer);
		                closetimer = null;
		        }
		}
		// close layer when click-out
		document.onclick = mclose;
		/*
		导航栏js代码结束
		*/
		var _bdhmProtocol=(("https:"==document.location.protocol)?" https://":" http://");document.write(unescape("%3Cscript src='"+_bdhmProtocol+"hm.baidu.com/h.js%3F78801593a8ba3263517390fdb526e665' type='text/javascript'%3E%3C/script%3E"));
	</script>
  </footer>
</body> 
</html>
